home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / ARCHIVES.SWG / 0010_ARJ File Viewer.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  7KB  |  246 lines

  1. {
  2. Author: Steve Wierenga
  3. ARJ Viewer
  4. }
  5. {Hello All:
  6. I am releasing these Units to the public domain.  They are Units to view Arj,
  7. Lzh, and Zip Files.  They are by no means professional, and probably have some
  8. bugs.  If you use these in your Programs and feel like giving me credit, I
  9. won't Object...  Here goes: }
  10.  
  11. Unit ArjV;
  12.  
  13. (**) Interface (**)
  14.  
  15. Uses
  16.   Dos,Crt;
  17.  
  18. Type
  19.   AFHeader = Record  { ArjFileHeader }
  20.     HeadID,
  21.     HdrSize   : Word;
  22.     HeadSize,
  23.     VerNum,
  24.     MinVerNum,
  25.     HostOS,
  26.     ArjFlag,
  27.     Method,
  28.     FType,
  29.     Reserved  : Byte;
  30.     FileTime,
  31.     PackSize,
  32.     OrigSize,
  33.     FileCRC   : LongInt;
  34.     FilePosF,
  35.     FileAcc,
  36.     HostData  : Word;
  37.   end;
  38.  
  39. Var
  40.   ff     : Integer;
  41.   b      : Byte;
  42.   f      : File;
  43.   sl     : LongInt;
  44.   NR     : Word;
  45.   FHdr   : ^AFHeader;
  46.   s,sss  : String;
  47.   Method : String[8];
  48.   l      : String[80];
  49.   Z,
  50.   totalu,
  51.   totalc : LongInt;
  52.   x,d    : LongInt;
  53.   Dt1,dt2: DateTime;
  54.   i,e    : Integer;
  55.   registered : Boolean;
  56.  
  57. Procedure ArjView(ArjFile : String);
  58. Function GAN(ArjFile : String): String;
  59.  
  60. (**) Implementation (**)
  61.  
  62. Procedure Terminate;
  63. begin
  64.   Write('ARCHPEEK could not find specified File.
  65.   Aborting...');
  66.   Halt;
  67. end;
  68.  
  69. Procedure ArjView(ArjFile : String);
  70. begin
  71.   New(FHdr);
  72.   Assign(f, arjFile);
  73.   {$I-}
  74.   Reset(F, 1);                     { Open File }
  75.   {$I+}
  76.   If IOResult <> 0 then
  77.     Terminate; { Specified File exists?}
  78.   registered := False;             { Unregistered }
  79.   if not registered then
  80.   begin
  81.     Writeln('ArchPeek 0.01Alpha [UNREGISTERED] Copyright 1993 Steve Wierenga');
  82.     Delay(200);
  83.   end;
  84.   SL := 0;z := 0;TotalU := 0; TotalC := 0;   { Init  Variables }
  85.   sss := GAN(ArjFile);                       { Get the Arj Filename }
  86.   Writeln('Arj FileName: ',SSS);
  87.   Write('   Name           Length      Size       Saved     Method     Date Time      ');
  88.   WriteLn('____________________________________________________________________________');
  89.   ff := 0;
  90.   Repeat
  91.     ff := ff + 1;
  92.     Seek(F,SL);
  93.     BlockRead(F,FHdr^,SizeOf(AFHeader),NR);     { Read the header }
  94.     If (NR = SizeOf(AFHeader)) Then
  95.     begin
  96.       s := '';
  97.       Repeat
  98.         BlockRead(F,B,1);               { Get Char For Compressed Filename }
  99.         If B <> 0 Then
  100.           s := s + Chr(b);              { Put Char in String }
  101.       Until B = 0;                      { Until no more Chars }
  102.       Case Length(S) Of                 { Straighten out String }
  103.         0  : s := s + '            ';
  104.         1  : S := s + '           ';
  105.         2  : s := s + '          ';
  106.         3  : S := S + '         ';
  107.         4  : S := S + '        ';
  108.         5  : S := S + '       ';
  109.         6  : S := S + '      ';
  110.         7  : S := S + '     ';
  111.         8  : S := S + '    ';
  112.         9  : S := S + '   ';
  113.         10 : S := S + '  ';
  114.         11 : S := S + ' ';
  115.         12 : S := S;
  116.       end;
  117.       z := z + 1;
  118.       UnPackTime(FHdr^.FileTime,dt2);  { Get the time of compressed File }
  119.       Case FHdr^.Method Of             { Get compression method }
  120.         0 : Method := 'Stored  ';
  121.         1 : Method := 'Most    ';
  122.         2 : Method := '2nd Most';
  123.         3 : Method := '2nd Fast';
  124.         4 : Method := 'Fastest ';
  125.       end;
  126.       Write( ' ',S,FHdr^.OrigSize:9,FHdr^.PackSize:10);
  127.       { Write Filesizes }
  128.       If ff > 1 then
  129.         { Don't get first Arj File in Arj File }
  130.         Write( (100-FHdr^.PackSize/FHdr^.OrigSize*100):9:0,'%',Method:15)
  131.          { Write ratios, method }
  132.         Else
  133.           Write( Method:25);
  134.       Case dt2.month of               { Show date of compressed File }
  135.         1..9   : Write( '0':4,dt2.month);
  136.         10..12 : Write( dt2.month:4);
  137.       end;
  138.       Write( '/');
  139.       Case dt2.day of
  140.         1..9   : Write( '0',dt2.day);
  141.         10..31 : Write( dt2.day);
  142.       end;
  143.       Write( '/');
  144.       Case dt2.year of
  145.         1980 : Write( '80');
  146.         1981 : Write( '81');
  147.         1982 : Write( '82');
  148.         1983 : Write( '83');
  149.         1984 : Write( '84');
  150.         1985 : Write( '85');
  151.         1986 : Write( '86');
  152.         1987 : Write( '87');
  153.         1988 : Write( '88');
  154.         1989 : Write( '89');
  155.         1990 : Write( '90');
  156.         1991 : Write( '91');
  157.         1992 : Write( '92');
  158.         1993 : Write( '93');
  159.         1994 : Write( '94');
  160.         1995 : Write( '95');
  161.         1996 : Write( '96');
  162.       end;
  163.       Case dt2.hour of                          { Show time of compressed File }
  164.         0..9   : Write( '0':2,dt2.hour,':');
  165.         10..23 : Write( dt2.hour:3,':');
  166.       end;
  167.       Case dt2.min of
  168.         0..9   : Write( '0',dt2.min,':');
  169.         10..59 : Write( dt2.min,':');
  170.       end;
  171.       Case dt2.sec of
  172.         0..9   : Writeln( '0',dt2.sec);
  173.         10..59 : Writeln( dt2.sec);
  174.       end;
  175.       TotalU := TotalU + FHdr^.OrigSize; { Increase total uncompressed size }
  176.       TotalC := TotalC + FHdr^.PackSize; { Increase total compressed size }
  177.       Repeat
  178.         BlockRead(F,B,1);
  179.       Until b = 0;
  180.       BlockRead(F,FHdr^.FileCRC,4);      { Go past File CRC }
  181.       BlockRead(f,NR,2);
  182.       Sl := FilePos(F) + FHdr^.PackSize; { Where are we in File? }
  183.     end;
  184.  
  185.   Until (FHdr^.HdrSize = 0);  { No more Files? }
  186.   GetFTime(F,x);
  187.   UnPackTime(x,dt1);
  188.   WriteLn('============================================================================');
  189.   Write( (z-1):4,' Files',TotalU:12,TotalC:10,(100-TotalC/TotalU*100):9:0,'%');
  190.   Case dt1.month of                  { Get date and time of Arj File }
  191.     1..9   : Write( '0':19,dt1.month);
  192.     10..12 : Write( dt1.month:20);
  193.   end;
  194.   Write( '/');
  195.   Case dt1.day of
  196.     1..9   : Write( '0',dt1.day);
  197.     10..31 : Write( dt1.day);
  198.   end;
  199.   Write( '/');
  200.   Case dt1.year of
  201.     1980 : Write( '80');
  202.     1981 : Write( '81');
  203.     1982 : Write( '82');
  204.     1983 : Write( '83');
  205.     1984 : Write( '84');
  206.     1985 : Write( '85');
  207.     1986 : Write( '86');
  208.     1987 : Write( '87');
  209.     1988 : Write( '88');
  210.     1989 : Write( '89');
  211.     1990 : Write( '90');
  212.     1991 : Write( '91');
  213.     1992 : Write( '92');
  214.     1993 : Write( '93');
  215.     1994 : Write( '94');
  216.     1995 : Write( '95');
  217.     1996 : Write( '96');
  218.   end;
  219.   Case dt1.hour of
  220.     0..9   : Write( '0':2,dt1.hour,':');
  221.     10..23 : Write( dt1.hour:3,':');
  222.   end;
  223.   Case dt1.min of
  224.     0..9   : Write( '0',dt1.min,':');
  225.     10..59 : Write( dt1.min,':');
  226.   end;
  227.   Case dt1.sec of
  228.     0..9   : Writeln( '0',dt1.sec);
  229.     10..59 : Writeln( dt1.sec);
  230.   end;
  231.   Close(f);
  232.   Dispose(FHdr);  { Done }
  233. end;
  234.  
  235. Function GAN(ARJFile:String): String;
  236. Var
  237.   Dir  : DirStr;
  238.   Name : NameStr;
  239.   Exts : ExtStr;
  240. begin
  241.   FSplit(ARJFile,Dir,Name,Exts);
  242.   GAN := Name + Exts;
  243. end;
  244.  
  245. end.
  246.